Part Number Hot Search : 
2SC4098 SELS6 R2000 74VHC574 04304 XE0052S2 P1SPNC01 ES8374
Product Description
Full Text Search
 

To Download AN2615 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  august 2007 rev 1 1/37 AN2615 application note a high precision, low cost, single supply adc for positive and negative input voltages introduction in general the adc embedded in the st7 microcontroller is enough for most applications. but, in some cases it is necessary to measure both positive and negative voltages. this requires an external adc with this particular capability. most external adcs require a dual supply to be able to do this. however, microcon troller-based applications usually only have a positive supply available. this application note describes a technique for implementing an adc for measuring both positive and negative input voltages while opera ting from a single (positive) supply. this converter is based on a voltage-to-time conversion technique. like other slope converters, this adc also uses an integrating capacitor, bu t the measured time is inversely proportional to the input voltage. an additional comparator with a voltage reference is used to improve conversion accuracy. as shown in the circuit diagram ( figure 1 on page 6 ), the converter is implemented using an integrating capacitor, resistor, external op-amp, comparators and some microcontroller i/o pins. the st72f264 microcontroller is used in this application note as an example, but the implementation is feasible using any st7 microcontroller. the 16-bit timer of the microcontroller measures the time using its input capture pins (pb0 and pb2). these pins are connected to the output of the comp1 and comp2 comparators. the i/o pins pb1 and pb3 are used to switch the m1 and m2 switches on or off. the circuit could also work with a microcontroller equipped with an 8-bit timer. only a small modification to the software would be needed. www.st.com
contents AN2615 2/37 contents 1 circuit diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2 theory of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.1 advantage of using two comparators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 3 timing diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 4 circuit analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 5v out vs time diagram for different input volt ages . . . . . . . . . . . . . . . . . 10 6 characteristics of different slope converters . . . . . . . . . . . . . . . . . . . . 11 6.1 single-slope converter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 6.1.1 single-slope converter timing diagram . . . . . . . . . . . . . . . . . . . . . . . . . . 11 6.2 dual-slope converter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 6.2.1 dual-slope converter timing diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 6.3 solution presented in this application note . . . . . . . . . . . . . . . . . . . . . . . . 13 7 error analysis/constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 7.1 input offset voltage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 7.2 correction factor for the product of r*c . . . . . . . . . . . . . . . . . . . . . . . . . . 14 7.3 value of charging resistance r . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 7.4 charging capacitor c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 7.5 16-bit timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 7.6 effect of temperature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 7.7 comparator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 8 voltage references . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 9 hardware setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 10 algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 11 result . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
AN2615 contents 3/37 11.1 positive input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 11.2 negative input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 11.3 effect of the capacitor value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 12 conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 13 references and bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 appendix a input stage conditions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 a.1 case 1: voltage measurement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 a.2 case 2: current measurement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 appendix b application board schema tics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 appendix c bill of materials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 appendix d software flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 d.1 code size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 14 revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
list of tables AN2615 4/37 list of tables table 1. results for positive input voltages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 table 2. results for negative input voltages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 table 3. bill of materials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 table 4. code size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 table 5. document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
AN2615 list of figures 5/37 list of figures figure 1. circuit diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 figure 2. relationship between vout and time for a given input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 figure 3. timing diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 figure 4. v out vs time for different input voltages. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 figure 5. single-slope converter circuit diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 figure 6. single-slope converter timing diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1 figure 7. dual-slope converter circuit diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 figure 8. dual-slope converter timing diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 figure 9. v in versus time in AN2615 solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 figure 10. voltage reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 figure 11. hardware setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 figure 12. algorithm flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 figure 13. results for positive input. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 figure 14. measured vs input for positive voltages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 figure 15. error vs input for positive input voltages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 figure 16. results for negative input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 figure 17. measured vs input for negative voltages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 5 figure 18. error vs input for negative input voltages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 figure 19. results for positive input with a 10 f capacitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 figure 20. voltage measurement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 figure 21. potential divider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 figure 22. use of input buffer for voltage measurement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 figure 23. current measurement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 figure 24. application board schematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
circuit diagram AN2615 6/37 1 circuit diagram figure 1. circuit diagram 1. v1 < v2 < v3 pb1 m1 r s c amp v out 358 d i v1 r pb3 m2 v in v2 pb2 comp2 358 v3 pb0 comp1 358
AN2615 theory of operation 7/37 2 theory of operation v in is the input voltage. the voltages across resistor r are the reference voltage v 1 and the input voltage v in . due to the properties of the op-amp, v 1 is output on the inverting pin of the op-amp. therefore, for a given input voltage, the current flowing through resistor r is constant. let this current be i. current i charges the capacitor c, and output starts increasing in a positive direction for the input v in <= v 1 (input v in > v 1 charges in the opposite direction). the output is captured at two instants using the two output comparators at voltage references v 2 and v 3 . the time corresponding to voltage levels v 2 and v 3 are t 2 and t 3 respectively. the final reading of time t m is taken as the difference of t 3 and t 2 . the input voltage is calculated from this difference through the formulae given in the circuit analysis. this technique can only be used where the input voltage varies slowly, otherwise the charging of the capacitor is non-linear. 2.1 advantage of using two comparators the purpose of using the second comparator (comp2) can be understood from the diagram below ( figure 2 ), which shows the relationship between the op-amp output (amp in figure 1: circuit diagram on page 6 ) and the time for a given input value. figure 2. relationship between v out and time for a given input the time is measured as the difference of the two timer readings (t3 -t2) for the same slope. so factors like the residua l voltage of the capacitor ( v c (0+)) and any other constant errors (like the effect of output offset voltage) on the output side of the op-amp are subtracted. so its performance is better than a single-slope converter. v out v3 v2 v1 t2 t3 time (t) t m point of uncertainty
timing diagram AN2615 8/37 3 timing diagram figure 3 shows the overall operation of the adc. initially the capacitor is in the reset state (m1- on and m2- off), the op-amp output v out is at v 1 and so, the output of both comparators, comp1 and comp2 is high. capacitor charging can be started by switching m1 - off and m2 - on. when the charging starts, v out rises. when v out becomes greater than v 2 , a falling edge occurs on comp1. this causes an input capture at pin pb2 and software reads the timer value t 2 . when v out becomes greater than v 3 , a falling edge occurs on comp2. again this causes an input capture at pin pb0 and software reads the timer value t 3 . the capacitor is discharged by switching m1 - on and m2- off. after this, the adc can be kept in reset condition by switching m1 - on and m2 - off or we can continue repeating the same process and make more measurements. figure 3. timing diagram charging v3 v out v2 v1 0 comp1 comp2 m1 m2 t2 t3 time (t) t m t m time discharg. time settling time
AN2615 circuit analysis 9/37 4 circuit analysis in this analysis, it is assumed that there is no noise present and the i/p offset voltage of the op-amp is negligible. i = (v 1 ? v in )/r = c * dv c /dt where, v c = v out ? v 1 and current ?i? is constant for a given input. applying the laplace transform: (v 1 ? v in )/s * r = c * (s v c (s) ? v c (0+)) or, (v 1 ? v in )/s 2 = (r * c) * ( v c (s) - v c (0+)/s) applying the inverse laplace transform, we get (v 1 ? v in ) * t = (r * c) * ( v c (t) - v c (0+) ) ------------------- (1) as shown in figure 3: timing diagram on page 8 at t = t 2 , v c (t 2 ) = v 2 ? v 1 and, at t =t 3 , v c (t 3 )= v 3 ? v 1 so, (v 1 ? v in ) * t 2 = (r * c) * (v 2 ? v 1 - v c (0+)) ------------------- (2) and, (v 1 ? v in ) * t 3 = (r * c) * (v 3 ? v 1 - v c (0+)) ------------------- (3) equation (2) and equation (3) can both be used as the characteristic equation for this converter, but factors like vc(0+) and other constant errors remain present. but if we use both comparators, then we can remove these factors by subtracting equation (2) and equation (3). after subtracting equation (2) from equation (1) and rearranging we get: v in = v 1 - (r * c) *( v 3 ? v 2 )/(t 3 ?t 2 ) ------------------- (4) let measured time t 3 - t 2 = t m and we get: v in = v1 - (r * c) * ( v 3 ? v 2 )/t m ------------------- (5) by using equation (5) we can measure the value of v in depending on the value of t 3 and t 2 .
v out vs time diagram for different input voltages AN2615 10/37 5 v out vs time diagram for different input voltages in figure 4 , we can see the relationship between the v out and time for different input voltages. from the figure, it is clear that the conversion time for a negative input voltage is less than the time taken for a positive input voltage. figure 4. v out vs time for different input voltages 1. t m 1: for v in < 0; t m 2: for v in = 0; and t m 3: for v in > 0 (where tin1 < tin2 < tin3) 2. this adc works for the range v in <= v 1 but if the input voltage is greater than v 1 the direction of current i is inverted and the capacitor starts charging in the o pposite direction and conversion never takes place. 3. for negative voltage currents i, that depend on the difference v 1 - v in , is high, so the charging time for negative voltages is less than the positive voltages. effective time t m = t - t? v3 v2 v1 v in < 0 v in =0 v in > 0 v out t1? t2? t1 t3? t2 time (t) t3
AN2615 characteristics of different slope converters 11/37 6 characteristics of different slope converters 6.1 single-slope converter figure 5. single-slope converter circuit diagram 6.1.1 single-slope conve rter timing diagram here v in is directly proportional to the time measured. figure 6. single-slope converter timing diagram 1. here v in = k * t m the major sources of conversion errors are the correction factor for the r*c product and the input offset voltage. a single-slope converter requires a dual supply voltage op-amp to be able to measure the positive and negative voltages. r -v ref v int v in c v in time
characteristics of different slope converters AN2615 12/37 6.2 dual-slope converter figure 7. dual-slope converter circuit diagram 6.2.1 dual-slope converter timing diagram as shown in figure 8 a dual-slope adc has a charging phase followed by a fixed rate discharging phase. figure 8. dual-slope converter timing diagram the advantage of a dual-slope adc is that it is not dependent on the correction factor for the r*c product. however, the input offset volta ge problem still persists and this adc also requires a dual supply op-amp to be able to measure positive and negative voltages. out out r s1 gnd gnd 1 2 3 1 2 s0 s1 s2 clk cmp control logic enbl clk counter ctr clk -v in v ref v in 1 v in 2 -v ref -v ref charging phase fixed-rate discharge v in = v ref t charge t discharge time
AN2615 characteristics of different slope converters 13/37 6.3 solution presented in this application note in this application note, a sing le supply adc for positive and negative input voltages is described. it's input voltage is proportional to the inverse of the time measured. we can see in figure 9 below that as the input voltage becomes closer to v1, the conversion time also increases. for an input of v 1 , the conversion time is infinite (1/t m = 0 in figure 9 ). so the input voltage range depends on the value of v1 and the maximum delay that the application can tolerate. figure 9. v in versus time in AN2615 solution 1. v in = v 1 - (r * c) * (v 3 -v 2 ) /t m the significant advantage of this adc is its ability to measure positive and negative input voltages operating from single supply, while other solutions require a dual supply. also this converter does not require any negative voltage reference. again, as in the single slope converter, the major sources of error are the correction factor for r*c product and the input offset voltage. as shown figure 9 , the adc is capable of measuring the input voltage ranging +v ref to -v ref, where the absolute value of v ref is mod (v ref ) < v 1 so the input voltage range depends on the value of v 1 . 1/t m positive input negative input -v ref total input range (+v ref to -v ref ) v0 v in v 1 +v ref
error analysis/constraints AN2615 14/37 7 error analysis/constraints this adc can be used for measuring any slowly varying input (voltage/current), for example battery monitoring, and for measuring positive and negative input voltages. but, besides the need for accurate power supply and voltage references, the following factors also affect the accuracy of the conversion. 7.1 input offset voltage as mentioned previously, the output offset voltage is subtracted from the input, but the input offset voltage of the op-amp (amp) still remains present an d is directly added to v 1 . for measurement purposes, let us refer to the input offset voltage of the op-amp as k offset . 7.2 correction factor for the product of r*c as the value of the r and c changes with time and temperature, the factor r * c also changes. let the correction factor be k gain . then eq(5) becomes, v in = v1 + k offset ? k gain * (r * c) *(v3 -v2)/tm ------------------ (6) the coefficients k offset and k gain can be calculated by measuring t m for two known input values. these factors can also be compensated by software calibration techniques (like using look-up tables or storing some known values). in the present example the first method is used to calculate these coefficients. 7.3 value of charging resistance r if the charging resistance ?r? is too high then the current ?i ? is comparable to the input bias current of the op-amp, which can affect the output. also if it is too low then the current flowing through it is significant so the capac itor is charged very fast. this affects the measurement accuracy of the adc. 7.4 charging capacitor c up to this point we have assumed that capacitor c discharges completely from the previous conversion. however, this is not so in actual practice and a few millivolts worth of charge (which adds to the offset voltage), may remain on the capacitor. this effect is called capacitor dielectric absorption and varies depen ding on the capacitor's dielectric material voltage to which it was charged during the last charge cycle and the amount of time the capacitor has had to discharge. also due to this effect, the output of the capacitor may not be linear over the whole conversion range. so it is very important to choose the right capacitor for your requirements. while teflon capacitors exhibit the lowest dielectric absorption, polystyrene and polyethylene are also excellent. ceramic, glass and mica are fair, while tantalum and electrolytic types are poor choices for a/d applications. also, as integrating adc?s are dependent on the integration of the current flowing through capacitor c, they do the averaging. so, the larger the value of the capacitor, the longer the
AN2615 error analysis/constraints 15/37 conversion time and the better the accuracy. in conclusion, there is always a trade-off between conversion time and accuracy. 7.5 16-bit timer a 16-bit timer is used as the counter that meas ures the conversion time. overflows are also taken into account, so we can also use an 8-bit timer. the resolution of the adc depends on the operating frequency of the timer. 7.6 effect of temperature the value and characteristics of each component varies with temperature. the effect of temperature can be broadly categorized as ?offset drift? and ?gain drift?. so we need to compensate the adc for each significant change in temperature. 7.7 comparator the comparators are the corner stone of the a/d conversion process. the ability of the comparator to detect small voltage/current changes makes the comparator very important in the a/d conversion process. any degradation of the intended behaviour of the comparator, which is most usually caused by unwanted noise, leads to the degradation of the adc?s ability to measure low voltages.
voltage references AN2615 16/37 8 voltage references the following circuit is used to produce the different voltage references. figure 10. voltage reference +5v v dd gnd r1 r2 c1 c2 v ref
AN2615 hardware setup 17/37 9 hardware setup figure 11. hardware setup the external adc is interfaced to the st7 microcontroller the input capture pins pb0 and pb2 are used for capturing the pulse from the comparators at two instants (when the output is equal to v 2 and v 3 respectively), while pb1 and pb3 ar e used for controlling the voltage at the gate of the m1 and m2 switches (on/off the mosfet). the results of the a/d conversion are displayed on the windows hyper terminal application through an rs232-sci interface. the general schematics of the board are given in appendix b: application board schematics on page 31 . 0134.85 mv v in v dd comp1 external adc m1 comp2 m2 pb0 pb1 pb2 pb3 st72 td0 gnd application board rs232 communication rs232 interface hyper terminal gnd multimeter v dd
algorithm AN2615 18/37 10 algorithm figure 12. algorithm flowchart start convert the timer reading in to voltage and send the result on the pc through sci-rs232 interface 1 second delay ye s pc through sci-rs 232 interface decrement count conversion complete? no 1 second delay initialize i/o,timer and sci start conversion calculate the average and display on the count > = 0? ye s no count = 16 calibrate the adc start new conversion
AN2615 result 19/37 11 result the result is given for a capacitor value of 100 f. so the conversion time is long. the conversion time can be reduced by choosing a ca pacitor with a lower value but accuracy is also reduced. other parameters are as follows: r = 10 k, v 1 = 1.5 v, v 2 = 2v and v 3 = 3 v so: r * c = (10 k) * (100 f) = 1 s the input range is taken as +1v to -1v, where mod (v ref ) (= 1 v) is less than v 1 . the conversion time is in the range 1 to 3 s. the settling time (as shown in figure 3: timing diagram on page 8 ) is fixed at 1s. the adc is calibrated by reading two known input voltages afterwhich k offset and k gain are calculated. the input voltage v in is taken from a voltage source. 11.1 positive input in figure 13 , an example of the readings measured by the converter, which are sent to the hyper terminal, are shown. t avg is the average of 16 conversions, and v avg is the calculated value in terms of voltage. the difference of the maximum and minimum value among the 16 values is also shown. figure 13. results for positive input
result AN2615 20/37 in ta bl e 1 , the readings are shown for positive input voltages ranging from 0 to 1 v. v in is the voltage measured by the multimeter. v measured (equal to v avg ) is the average voltage measured by the converter in a loop of 16. the last column shows the difference in the maximum and minimum readings of the values measured by the converter in the loop. this shows the variations recorded in the readings. table 1. results for positive input voltages sl no v in (mv) (taken from multimeter) v measured (mv) difference (mv) (v measured - v in ) error in max and min input measured in the loop (mv) 1 8.93 8.93 0 0.45 2 18.94 18.98 0.04 0.25 3 28.82 28.87 0.05 0.21 4 38.72 38.78 0.06 0.39 5 49.07 49.13 0.06 0.46 6 58.93 59.02 0.09 0.38 7 68.82 68.92 0.1 0.08 8 79.12 79.25 0.13 0.39 9 88.98 89.07 0.09 0.33 10 98.85 98.98 0.13 0.12 11 108.75 108.9 0.15 0.37 12 119.05 119.19 0.14 0.43 13 128.95 129.13 0.18 0.29 14 138.57 138.76 0.19 0.24 15 158.75 158.96 0.25 0.25 16 178.97 179.18 0.21 0.4 17 198.68 198.91 0.23 0.1 18 218.83 219.1 0.27 0.37 19 239.08 239.35 0.27 0.34 20 258.55 258.83 0.28 0.14 21 278.8 279.11 0.31 0.19 22 299.02 299.34 0.32 0.31 23 318.68 319.09 0.41 0.37 24 338.93 339.29 0.36 0.35 25 358.38 358.78 0.4 0.39 26 378.62 378.98 0.36 0.36 27 398.85 399.25 0.4 0.27 28 438.84 439.23 0.39 0.15 29 478.64 478.93 0.29 0.35
AN2615 result 21/37 30 498.75 499.23 0.48 0.09 31 519 519.41 0.41 0.32 32 538.69 539.1 0.41 0.28 33 558.91 559.3 0.39 0.11 34 578.63 579.03 0.4 0.3 35 598.65 599.01 0.36 0.28 36 638.6 638.99 0.39 0.26 37 678.93 679.3 0.37 0.14 38 718.6 718.93 0.33 0.14 39 758.61 758.93 0.32 0.23 40 798.53 798.83 0.3 0.17 41 838.7 838.94 0.24 0.19 42 858.49 858.68 0.19 0.2 43 878.55 878.72 0.17 0.13 44 898.76 898.92 0.16 0.19 45 918.53 918.61 0.08 0.13 46 938.46 938.55 0.09 0.15 47 958.68 958.72 0.04 0.1 48 978.4 978.38 -0.02 0.14 49 998.63 998.56 -0.07 0.14 50 1018.8 1018.68 -0.12 0.18 table 1. results for positive input voltages (continued) sl no v in (mv) (taken from multimeter) v measured (mv) difference (mv) (v measured - v in ) error in max and min input measured in the loop (mv)
result AN2615 22/37 figure 14 shows the relationship between the voltage measured by the adc v measured (average of the 16 readings measured by the converter) and the input voltage v in . figure 14. measured vs input for positive voltages figure 15 shows the relationship between the error voltage (as given in ta bl e 1 in the column ?difference (v measured - v in ?)) and the input voltage v in . figure 15. error vs input for positive input voltages note: it may be seen from the readings in ta b l e 1 and figure 15 , that for the positive input between 0 to 1 v the maximum error is around 500 v for an average of 16 conversions. thus the difference between the maximum and minimum values in a loop of 16 is around 500 v. this shows that averaging has increased accuracy. the accuracy without averaging is approx 1mv. the variations of the 16 values may be due to changes in the input voltage itself, as the time taken for 16 readings is very long (around 16 s).
AN2615 result 23/37 11.2 negative input similar to the positive input voltages, the readings for negative input voltage are taken in a loop of 16 as shown in figure 16 . figure 16. results for negative input
result AN2615 24/37 ta bl e 2 shows the readings for negative input voltages ranging from 0 to -1 v with the same parameter notations as table 1: results for positive input voltages on page 20 . table 2. results for negative input voltages sl no v in (mv) (taken from multimeter) v measured (mv) difference (mv) (v measured - v in ) error in max and min input measured in the loop (mv) 1 -9.23 -9.17 0.06 0.43 2 -18.92 -18.84 0.08 0.14 3 -28.96 -29.04 -0.08 0.27 4 -38.76 -38.89 -0.13 0.38 5 -49.03 -49.14 -0.11 0.37 6 -58.88 -59 -0.12 0.24 7 -68.74 -68.9 -0.16 0.8 8 -79.03 -79.2 -0.17 0.22 9 -88.88 -89.06 -0.18 0.34 10 -98.76 -98.96 -0.2 0.4 11 -128.87 -129.13 -0.26 0.32 12 -148.76 -149.07 -0.31 0.32 13 -178.9 -179.21 -0.31 0.39 14 -198.6 -198.94 -0.34 0.11 15 -218.73 -219.12 -0.39 0.43 16 -248.59 -249.04 -0.45 0.2 17 -268.81 -269.32 -0.51 0.46 18 -298.91 -299.51 -0.6 0.15 19 -318.61 -319.25 -0.64 0.38 20 -348.67 -349.37 -0.7 0.37 21 -378.42 -379.23 -0.81 0.23 22 -398.71 -399.57 -0.86 0.48 23 -418.45 -419.33 -0.88 0.25 24 -448.52 -449.5 -0.98 0.47 25 -478.36 -479.41 -1.05 0.26 26 -498.56 -499.69 -1.13 0.4 27 -538.52 -539.73 -1.21 0.38 28 -578.4 -579.8 -1.4 0.47 29 -618.63 -620.1 -1.47 0.19 30 -658.52 -660.17 -1.65 0.53 31 -698.51 -700.28 -1.77 0.26 32 -738.65 -740.44 -1.79 0.16
AN2615 result 25/37 figure 17 shows the relationship between measured voltages v measured (average of the 16 readings measured by the converter) and input voltage v in (as measured by the multimeter) for negative voltages. figure 17. measured vs input for negative voltages figure 18. error vs input for negative input voltages figure 18 , shows that for negative input voltages varying from 0 to -1 v, the maximum error is around -2.89 mv for -1 v input. an error of 0.5 mv occurs for an input value of -269 mv 33 -778.54 -780.59 -2.05 0.37 34 -818.25 -820.42 -2.17 0.43 35 -858.27 -860.61 -2.34 0.56 36 -898.57 -901.07 -2.5 0.2 37 -938.31 -940.94 -2.63 0.67 38 -978.21 -981.03 -2.82 0.43 table 2. results for negative input voltages (continued) sl no v in (mv) (taken from multimeter) v measured (mv) difference (mv) (v measured - v in ) error in max and min input measured in the loop (mv)
result AN2615 26/37 and it increases gradually afterwards. the maximum difference between the maximum and minimum value in a loop is around 600 v. so, the accuracy of the average value measured is around 3 mv. without averaging, accuracy is around 3.6 mv. 11.3 effect of the capacitor value as discussed in section 7: error analysis/constraints on page 14 , reducing the r*c time constant by reducing the value of r or c, reduces the accuracy. readings were taken with a 10 f capacitor and accuracy of the adc was found to be reduced. figure 19 gives an example of readings with a 10 f capacitor. figure 19. results for positive input with a 10 f capacitor figure 19 shows that variation in the readings taken in a loop of 16 is around 5 - 6 mv which is approximately 10 times higher than the readings for the 100 f. this indicates that there is always a trade-off between conversion time and the desired accuracy.
AN2615 conclusion 27/37 12 conclusion this application note presents a technique for implementing a positive supply adc, capable of measuring slowly-varying positive and nega tive input voltages with high precision. accuracy of the converter depends on the different parameters involved. greater accuracy can be achieved with careful board design, more precise components and by taking into consideration all the factors discussed in the document.
references and bibliography AN2615 28/37 13 references and bibliography the following articles and reports provide useful information: 1. an1636, understanding and minimising adc conversion errors 2. comparators and bistable circuits, ece60l lecture notes, winter 2002 3. selecting the right buffer operational amplifier for an a/d converter, application report sloa050, august 2000, texas instruments 4. mosfet device physics and operation by t ytterdal, y cheng and ta fjeldly, ? 2003, john wiley and sons, isbn: 0-471-49869-6 5. comparators and offset cancellation te chniques by jieh-tsorng wu, 2003, national chiao-tung university department of electronics engineering 6. reducing noise in data acquisition systems by fred r schraff, pe iotech inc., adapted from an article that appeared in the april 1996 edition of sensors magazine, helmers publishing 7. how do adcs work? by martin rowe, senior technical editor, 7/1/2002, test and measurement world
AN2615 input stage conditions 29/37 appendix a input stage conditions the adc described here can be used for measuring both voltage and current with slight changes in set-up in each case. a.1 case 1: voltage measurement there are two ways in which the input voltage appears at the adc input. the first way is that input comes directly from a voltage source as shown in figure 20 . figure 20. voltage measurement in figure 20 above, there are no problems. however, if the input comes from a potential divider circuit as shown in figure 21 , the effective input voltage v in is the result of the drop across r2 due to the current i and current i in . figure 21. potential divider in this case an input buffer has to be used to overcome the problem (see figure 22: use of input buffer for voltage measurement on page 30 ). c o/p v1 r i v in r1 gnd i v in r2 r1 i in
input stage conditions AN2615 30/37 figure 22. use of input buffer for voltage measurement a.2 case 2: current measurement figure 23 shows the current measurement circuit. figure 23. current measurement v in = (i in + i) * r sense = i in * (1 + i/i in ) * r sense ------------ (1) i = (v 1 - v in )/r = v 1 /(r * (1 + r sense /r)) ------------ (2) the following points should be kept in mind while using r sense : 1. r sense should be chosen to correspond with the range of the current to be measured. 2. r sense affects the effective value of current i. to minimize its effect, it should be negligible compared to r. otherwise adc has to be compensated. o/p c r v1 i v in v in c o/p v1 r i v in r sense i in
AN2615 application board schematics 31/37 appendix b application board schematics figure 24. application board schematics j1 jack vin 1 gnd 2 vout 3 u1 lm7805 d1 in4007 c2 220uf/25v c1 100nf d2 led-green-3mm r1 330e c5 100nf c3 220uf/25v vdd dc power 9~14v dc 1 2 j3 5v max c4 10uf/25v gnd vcc s1 c15 100pf r8 4k7 vdd 1 2 j4 r9 1k reset 2 3 1 8 4 u4 lm358 2 3 1 8 6 5 7 4 u3 lm358 vdd 1 2 3 q2 mosfet n 1 2 3 q1 mosfet n d3 r10 10k r13 1e c14 100uf vin pb1 pb3 v3 v1 v2 vdd pb2 pb0 r2 3k5 r3 1k5 c7 100nf c6 100nf v1 vdd r4 3k3 r6 2k2 c9 100nf c8 100nf v2 vdd r7 2k2 r5 3k3 c11 100nf c10 100nf v3 vdd reset 1 osc1 2 osc2 3 vss 31 pb3 10 vdd 32 pa1 28 pa2 27 pa3 26 iccsel 30 nc 25 nc 24 pa4 23 pa5 22 pa6 21 pa7 20 pa0 29 pb2 11 pb1 12 pb0 13 pc5 14 pc4 15 pc3 16 pc0 19 ss/pb7 4 sck/pb6 5 miso/pb5 6 mosi/pb4 7 nc 8 nc 9 pc1 18 pc2 17 u2 st72f264 1 6 2 7 3 8 4 9 5 j8 db9 c1+ 1 v+ 2 c1- 3 c2+ 4 c2- 5 v- 6 t2out 7 r2in 8 r2out 9 t2in 10 t1in 11 r1out 13 r1in 12 t1out 14 gnd 15 vcc 16 u5 st3232 gnd c13 100nf c19 1uf 16v c18 1uf 16v c20 1uf 16v c21 1uf 16v vdd vdd sci 1 2 j5 rts sci1_rdi sci1_tdo sci_rts 1 2 j7 sci_rdi 1 2 j6 sci_tdo sci_tdo y1 16mhz c16 22pf c17 22pf pb3 pb2 pb1 pb0 vdd c12 100nf r11 10k r12 10k vdd pb2 pb0 1 2 j2
bill of materials AN2615 32/37 appendix c bill of materials ta bl e 3 gives the bill of material for each block of the schematics shown in figure 24 . table 3. bill of materials block designator part ty pe/number description adc r13 1e resistor r10 10 k ? resistor u3 lm358 dual op-amp u4 lm358 dual op-amp c14 100 f capacitor q2 stb100nf03l n - mosfet q1 stb100nf03l n - mosfet d3 in4007 diode voltage references c8 100 nf capacitor c9 100 nf capacitor c10 100 nf capacitor c11 100 nf capacitor c7 100 nf capacitor c6 100 nf capacitor r6 2.2 k ? resistor r7 2.2 k ? resistor r5 3.3 k ? resistor r4 3.3 k ? resistor r2 3.5 k ? resistor r3 1.5 k ? resistor sci u5 st3232 line driver c18 1f 16 v capacitor c19 1f 16 v capacitor c20 1f 16 v capacitor c21 1f 16 v capacitor j5 jumper con-2 j7 jumper con-2 j6 jumper con-2 c13 100 nf capacitor j8 db9 9 pin connector
AN2615 bill of materials 33/37 micro setup r12 10 k ? resistor r11 10 k ? resistor u2 st72f264 micro-controller c12 100 nf capacitor y1 16 mhz crystal oscillator crystal c17 22 pf capacitor c16 22 pf capacitor r9 1 k ? resistor reset r8 4.7 k ? resistor c15 100 pf capacitor s1 push button micro switch j4 con-2 jumper dc power c4 10 f/25 v capacitor c5 100 nf capacitor c1 100 nf capacitor c3 220 f/25 v capacitor c2 220 f/25 v capacitor r1 330e resistor j1 dc - jack dc - jack d2 led 3mm led-green u1 lm7805 voltage regulator d1 in4007 diode j2 jumper con-2 j3 power connector 2 pin connector table 3. bill of materials (continued) block designator part ty pe/number description
software flow AN2615 34/37 appendix d software flow the f cpu chosen is 8 mhz. k offset and k gain are calculated by taking a reading for two known inputs. the flow of software, used to implement the algorithm, is as follows: 1. the i/o pins, timer, sci (tx @ 9600 baud rate) and some global variables used in the adc are initialized. 2. a string is transmitted to check that the sci is working well. 3. settling time is fixed at 1 s for f cpu = 8 mhz. 4. some initial readings are taken and ignored while the adc stabilizes. 5. the control enters an infinite loop. 6. inside the infinite loop, there is a loop in which the adc captures the timer values 17 times. however, the first reading is ignored. 7. the remaining 16 captured values are converted into corresponding voltages (up to 10 v precision) and then transmitted to a pc fo r display by the hyper terminal after being converted into a buffer of ascii characters. 8. the average of 16 timer readings is taken and sent to the hyper terminal as a time value and a corresponding voltage in the same manner as described above. 9. the difference between the maximum and mi nimum captured value is also sent to the hyper terminal in the same way as in step 8. 10. the software enters an ?if? loop ?if (mcount == 18)?, wher e the adc is reset in order to measure the next input value. again, a few readings are ignored while the adc stabilizes. the counter an d other global variables are also initialized. 11. the software re-enters the loop of 17 conversions and executes step 6 to step 9. this process continues until the system is reset manually.
AN2615 software flow 35/37 d.1 code size the software given is for guidance only. here the display is done for up to 10 v precision. the user can modify and use their own code for display of the data. ta bl e 4 summarizes the code size. depending on the compiler and memory placement, these values can change. the ram requirements are not provided and the user has the choice to place the variables as global or local. . note: some floating point operations are used in this software for display purposes only. it is left to the user to use the floating point operation or not as per his application requirement. table 4. code size no. function name code size ( bytes) adcsys 1 acquisition 128 2 start_capturing 7 3 reset_adc 5 4 adc_initializevar 29 5 iscaptured 13 6 delay_second 44 7 io_init 37 8 timera_init 47 9 timer_interrupt_routine 170 main 10 main 1493 11 timera_it_routine 38 12 conversion_timerreadingtorealinput 116 13 sci_init 25 14 sci_sendbuffer 30 15 sci_istransmissioncompleted 8 16 dummy_capturing 26
revision history AN2615 36/37 14 revision history table 5. document revision history date revision changes 23-aug-2007 1 initial release
AN2615 37/37 please read carefully: information in this document is provided solely in connection with st products. stmicroelectronics nv and its subsidiaries (?st ?) reserve the right to make changes, corrections, modifications or improvements, to this document, and the products and services described he rein at any time, without notice. all st products are sold pursuant to st?s terms and conditions of sale. purchasers are solely responsible for the choice, selection and use of the st products and services described herein, and st as sumes no liability whatsoever relating to the choice, selection or use of the st products and services described herein. no license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. i f any part of this document refers to any third party products or services it shall not be deemed a license grant by st for the use of such third party products or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoev er of such third party products or services or any intellectual property contained therein. unless otherwise set forth in st?s terms and conditions of sale st disclaims any express or implied warranty with respect to the use and/or sale of st products including without limitation implied warranties of merchantability, fitness for a parti cular purpose (and their equivalents under the laws of any jurisdiction), or infringement of any patent, copyright or other intellectual property right. unless expressly approved in writing by an authorized st representative, st products are not recommended, authorized or warranted for use in milita ry, air craft, space, life saving, or life sustaining applications, nor in products or systems where failure or malfunction may result in personal injury, death, or severe property or environmental damage. st products which are not specified as "automotive grade" may only be used in automotive applications at user?s own risk. resale of st products with provisions different from the statements and/or technical features set forth in this document shall immediately void any warranty granted by st for the st product or service described herein and shall not create or extend in any manner whatsoev er, any liability of st. st and the st logo are trademarks or registered trademarks of st in various countries. information in this document supersedes and replaces all information previously supplied. the st logo is a registered trademark of stmicroelectronics. all other names are the property of their respective owners. ? 2007 stmicroelectronics - all rights reserved stmicroelectronics group of companies australia - belgium - brazil - canada - china - czech republic - finland - france - germany - hong kong - india - israel - ital y - japan - malaysia - malta - morocco - singapore - spain - sweden - switzerland - united kingdom - united states of america www.st.com


▲Up To Search▲   

 
Price & Availability of AN2615

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X